package com.test.java;

import java.util.Scanner;

/**
 * 字符串APPAPT中包含了两个单词“PAT”，其中第一个PAT是第2位(P),第4位(A),第6位(T)；第二个PAT是第3位(P),第4位(A),第6位(T)。
 * 现给定字符串，问一共可以形成多少个PAT？
 * =============================================================
 * Version          Author          Date            Description
 * 1.0              白建         2017/12/29             创建
 * =============================================================
 */
public class Java_31
{

    public static void main(String[] args)
    {

        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        StringBuilder stringBuilder = new StringBuilder(input);

        int P_before, T_after;
        int count = 0;
        while (stringBuilder.indexOf("A") != -1)
        {
            P_before = 0;
            T_after = 0;
            for (int i = 0; i < stringBuilder.indexOf("A"); i++)
            {
                if (stringBuilder.charAt(i) == 'P')
                {
                    P_before++;
                }
            }
            for (int i = stringBuilder.indexOf("A"); i < stringBuilder.length(); i++)
            {
                if (stringBuilder.charAt(i) == 'T')
                {
                    T_after++;
                }
            }
            count += T_after * P_before;
            stringBuilder.setCharAt(stringBuilder.indexOf("A"), '-');
        }
        System.out.println(count % 1000000007);
    }
}
